<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>defer</title>
</head>

<body>
    <div id="test"></div>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const defer = (handler, ...args) => setTimeout(handler, 1, ...args);
        defer(console.log, 'a');
        console.log('b');
        const longRunningFunction = () => {
            document.querySelector('#test').innerHTML = 'Hello';
        }
        defer(longRunningFunction);
    </script>
</body>

</html>